package cn.exrick.xboot.modules.projectinfo.serviceimpl;

import cn.exrick.xboot.common.vo.PageVo;
import cn.exrick.xboot.common.vo.SearchVo;
import cn.exrick.xboot.modules.bicmktbiddinginfo.entity.BidAndBidBack;
import cn.exrick.xboot.modules.bicmktbiddinginfo.entity.RequestData;
import cn.exrick.xboot.modules.projectinfo.entity.*;
import cn.exrick.xboot.modules.projectinfo.mapper.ProjectInfoMapper;
import cn.exrick.xboot.modules.projectinfo.service.IProjectInfoService;
import com.baomidou.dynamic.datasource.annotation.DS;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import java.lang.reflect.Field;
import java.util.*;
import java.util.stream.Collectors;

/**
 * 项目信息接口实现
 *
 * @author sdtf
 */
@Slf4j
@Service
@DS("other")
@Transactional
public class IProjectInfoServiceImpl extends ServiceImpl<ProjectInfoMapper, ProjectInfo> implements IProjectInfoService {

    @Autowired
    private ProjectInfoMapper projectInfoMapper;

    //    方法抽出
//    private static void extracted(DeptLife deptLife) {
//        if (deptLife.getDeptName().length() == 18) {
//            deptLife.setDeptName(deptLife.getDeptName().substring(13, 15) + "公司");
//        }
//        if (deptLife.getDeptName().length() == 5 && deptLife.getDeptName().endsWith("公司")) {
//            deptLife.setDeptName(deptLife.getDeptName().substring(0, 2) + "公司");
//        }
//        if (deptLife.getDeptName().contains("本部")) {
//            deptLife.setDeptName("山东省信息产业服务有限公司");
//        }
//        if (deptLife.getDeptName().contains("事业部")) {
//            deptLife.setDeptName("呼叫业务事业部");
//        }
//        if (deptLife.getDeptName().contains("通信技术公司")) {
//            deptLife.setDeptName("通信技术公司");
//        }
//        if (deptLife.getDeptName().contains("信息化业务")) {
//            deptLife.setDeptName("信息化业务部");
//        }
//        if (deptLife.getDeptName().contains("云网")) {
//            deptLife.setDeptName("云网公司");
//        }
//    }

//    private static void extracted1(RequireData deptLife) {
//        if (deptLife.getDeptName().length() == 18) {
//            deptLife.setDeptName(deptLife.getDeptName().substring(13, 15) + "公司");
//        }
//        if (deptLife.getDeptName().length() == 5 && deptLife.getDeptName().endsWith("公司")) {
//            deptLife.setDeptName(deptLife.getDeptName().substring(0, 2) + "公司");
//        }
//        if (deptLife.getDeptName().contains("本部")) {
//            deptLife.setDeptName("山东省信息产业服务有限公司");
//        }
//        if (deptLife.getDeptName().contains("事业部")) {
//            deptLife.setDeptName("呼叫业务事业部");
//        }
//        if (deptLife.getDeptName().contains("通信技术公司")) {
//            deptLife.setDeptName("通信技术公司");
//        }
//        if (deptLife.getDeptName().contains("信息化业务")) {
//            deptLife.setDeptName("信息化业务部");
//        }
//        if (deptLife.getDeptName().contains("云网")) {
//            deptLife.setDeptName("云网公司");
//        }
//    }

//    private static void extracted4(NumberAndMoneyTwice deptLife) {
//        if (deptLife.getDeptName().length() == 18) {
//            deptLife.setDeptName(deptLife.getDeptName().substring(13, 15) + "公司");
//        }
//        if (deptLife.getDeptName().length() == 5 && deptLife.getDeptName().endsWith("公司")) {
//            deptLife.setDeptName(deptLife.getDeptName().substring(0, 2) + "公司");
//        }
//        if (deptLife.getDeptName().contains("本部")) {
//            deptLife.setDeptName("山东省信息产业服务有限公司");
//        }
//        if (deptLife.getDeptName().contains("事业部")) {
//            deptLife.setDeptName("呼叫业务事业部");
//        }
//        if (deptLife.getDeptName().contains("通信技术公司")) {
//            deptLife.setDeptName("通信技术公司");
//        }
//        if (deptLife.getDeptName().contains("信息化业务")) {
//            deptLife.setDeptName("信息化业务部");
//        }
//        if (deptLife.getDeptName().contains("云网")) {
//            deptLife.setDeptName("云网公司");
//        }
//    }

//    private static void extracted2(ProjectNew deptLife) {
//        if (deptLife.getDeptName().length() == 18) {
//            deptLife.setDeptName(deptLife.getDeptName().substring(13, 15) + "公司");
//        }
//        if (deptLife.getDeptName().length() == 5 && deptLife.getDeptName().endsWith("公司")) {
//            deptLife.setDeptName(deptLife.getDeptName().substring(0, 2) + "公司");
//        }
//        if (deptLife.getDeptName().contains("本部")) {
//            deptLife.setDeptName("山东省信息产业服务有限公司");
//        }
//        if (deptLife.getDeptName().contains("事业部")) {
//            deptLife.setDeptName("呼叫业务事业部");
//        }
//        if (deptLife.getDeptName().contains("通信技术公司")) {
//            deptLife.setDeptName("通信技术公司");
//        }
//        if (deptLife.getDeptName().contains("信息化业务")) {
//            deptLife.setDeptName("信息化业务部");
//        }
//        if (deptLife.getDeptName().contains("云网")) {
//            deptLife.setDeptName("云网公司");
//        }
//    }

//    private static void extracted5(AllBoardData deptLife) {
//        if (deptLife.getDeptName().length() == 18) {
//            deptLife.setDeptName(deptLife.getDeptName().substring(13, 15) + "公司");
//        }
//        if (deptLife.getDeptName().length() == 5 && deptLife.getDeptName().endsWith("公司")) {
//            deptLife.setDeptName(deptLife.getDeptName().substring(0, 2) + "公司");
//        }
//        if (deptLife.getDeptName().contains("本部")) {
//            deptLife.setDeptName("山东省信息产业服务有限公司");
//        }
//        if (deptLife.getDeptName().contains("事业部")) {
//            deptLife.setDeptName("呼叫业务事业部");
//        }
//        if (deptLife.getDeptName().contains("通信技术公司")) {
//            deptLife.setDeptName("通信技术公司");
//        }
//        if (deptLife.getDeptName().contains("信息化业务")) {
//            deptLife.setDeptName("信息化业务部");
//        }
//        if (deptLife.getDeptName().contains("云网")) {
//            deptLife.setDeptName("云网公司");
//        }
//    }


    /**
     * 今年立项，在建，关闭项目数量金额
     */
    @Override
    public RequireData ProjectNumberAndMoneyByYear() {
        //本年立项项目数量和金额
        RequireData requireData = projectInfoMapper.ProjectNumberAndMoneyByYear();
        //本年在建项目数量和金额
        RequireData requireData1 = projectInfoMapper.IsProgectNumberAndMoneyByYear();
        //本年关闭项目数量和金额
        RequireData requireData2 = projectInfoMapper.ProjectsFinishedNumberAndMoneyByYear();
        //封装对象并进行返回
        requireData.setNumberIsProject(requireData1.getNumberIsProject());
        requireData.setMoneyIsProject(requireData1.getMoneyIsProject());
        requireData.setNumberProjectFinish(requireData2.getNumberProjectFinish());
        requireData.setMoneyProjectFinish(requireData2.getMoneyProjectFinish());
        //对空值进行判断
        if (requireData.getNumberProject() == null) {
            requireData.setNumberProject(0);
        }
        if (requireData.getNumberIsProject() == null) {
            requireData.setNumberIsProject(0);
        }
        if (requireData.getNumberProjectFinish() == null) {
            requireData.setNumberProjectFinish(0);
        }
        if (requireData.getMoneyProject() == null) {
            requireData.setMoneyProject(0L);
        }
        if (requireData.getMoneyIsProject() == null) {
            requireData.setMoneyIsProject(0L);
        }
        if (requireData.getMoneyProjectFinish() == null) {
            requireData.setMoneyProjectFinish(0L);
        }
        return requireData;
    }

    /**
     * 本月立项，在建，关闭项目数量金额
     */
    @Override
    public RequireData ProjectNumberAndMoneyByMonth() {
        //本年立项项目数量和金额
        RequireData requireData = projectInfoMapper.ProjectNumberAndMoneyByMonth();
        //本年在建项目数量和金额
        RequireData requireData1 = projectInfoMapper.IsProgectNumberAndMoneyByMonth();
        //本年关闭项目数量和金额
        RequireData requireData2 = projectInfoMapper.ProjectsFinishedNumberAndMoneyByMonth();
        //封装对象并进行返回
        requireData.setNumberIsProject(requireData1.getNumberIsProject());
        requireData.setMoneyIsProject(requireData1.getMoneyIsProject());
        requireData.setNumberProjectFinish(requireData2.getNumberProjectFinish());
        requireData.setMoneyProjectFinish(requireData2.getMoneyProjectFinish());
        //对空值进行判断
        if (requireData.getNumberProject() == null) {
            requireData.setNumberProject(0);
        }
        if (requireData.getNumberIsProject() == null) {
            requireData.setNumberIsProject(0);
        }
        if (requireData.getNumberProjectFinish() == null) {
            requireData.setNumberProjectFinish(0);
        }
        if (requireData.getMoneyProject() == null) {
            requireData.setMoneyProject(0L);
        }
        if (requireData.getMoneyIsProject() == null) {
            requireData.setMoneyIsProject(0L);
        }
        if (requireData.getMoneyProjectFinish() == null) {
            requireData.setMoneyProjectFinish(0L);
        }
        return requireData;
    }

    /**
     * 项目生命周期图标
     */
    @Override
    public LinkedList<Object> ProjectLife() {
//        创建三个集合
//        数量集合
        LinkedList<Long> NumList = new LinkedList<>();
//        名称集合
        LinkedList<String> NameList = new LinkedList<>();
//        返回数据集合
        LinkedList<Object> list = new LinkedList<>();
        //查询数量
        RequireData requireData = projectInfoMapper.ProjectLifeNumber();
//        数量集合
        NumList.add(requireData.getProjectLifeNumber1());
        NumList.add(requireData.getProjectLifeNumber2());
        NumList.add(requireData.getProjectLifeNumber3());
        NumList.add(requireData.getProjectLifeNumber4());
//        名称集合
        NameList.add("一年以内");
        NameList.add("1-2年");
        NameList.add("2-3年");
        NameList.add("三年以上");
//        集合转变为数组
        Object[] objects = NumList.toArray();
        Object[] objects1 = NameList.toArray();
        list.add(objects);
        list.add(objects1);
        return list;
    }

    /**
     * 项目类型图标
     */
    @Override
    public LinkedList<Object> ProjectType() {
//        创建三个集合
//        数量集合
        LinkedList<Long> NumList = new LinkedList<>();
//        名称集合
        LinkedList<String> NameList = new LinkedList<>();
//        返回数据集合
        LinkedList<Object> list = new LinkedList<>();
        List<RequireData> list1 = projectInfoMapper.ProjectType();
        for (RequireData requireData : list1) {
            if (requireData.getProjectTypeName() != null && requireData.getProjectTypeNumber() != 0) {
                NumList.add(requireData.getProjectTypeNumber());
                NameList.add(requireData.getProjectTypeName());
            }
        }
        Object[] objects = NumList.toArray();
        Object[] objects1 = NameList.toArray();
        list.add(objects);
        list.add(objects1);
        return list;
    }

    /**
     * 协同项目图标
     */
    @Override
    public LinkedList<Object> ProjectWithOther() {
//        创建三个集合
//        数量集合
        LinkedList<Long> NumList = new LinkedList<>();
//        名称集合
        LinkedList<String> NameList = new LinkedList<>();
//        返回数据集合
        LinkedList<Object> list = new LinkedList<>();
        List<RequireData> list1 = projectInfoMapper.ProjectWithOther();
//        封装数据
        for (int i = 2; i < 7; i++) {
            if (i < list1.size()) {
                RequireData requireData = list1.get(i);
                if (requireData.getProjectTypeNumber() != 0) {
                    NumList.add(requireData.getProjectTypeNumber());
                }
            }
        }
        NameList.add("主业总包");
        NameList.add("联合拓展");
        NameList.add("通服总包");
        Object[] objects = NumList.toArray();
        Object[] objects1 = NameList.toArray();
        list.add(objects);
        list.add(objects1);
        return list;
    }

    /**
     * 项目状态图表
     */
    @Override
    public LinkedList<Object> ProjectStatus() {
        //        创建三个集合
//        数量集合
        LinkedList<Long> NumList = new LinkedList<>();
//        名称集合
        LinkedList<String> NameList = new LinkedList<>();
//        返回数据集合
        LinkedList<Object> list = new LinkedList<>();
        List<RequireData> list1 = projectInfoMapper.ProjectStatus();
        for (RequireData requireData : list1) {
            if (requireData.getProjectStatusName() != null) {
                NumList.add(requireData.getProjectStatusNumber());
                NameList.add(requireData.getProjectStatusName());
            } else {
                requireData.setProjectStatusName("未知");
                NumList.add(requireData.getProjectStatusNumber());
                NameList.add(requireData.getProjectStatusName());
            }

        }
        list.add(NumList.toArray());
        list.add(NameList.toArray());
        return list;
    }


    /**
     * 新建重大项目
     */
    @Override
    public List<RequireData> ProjectNewByYear() {
        List<RequireData> list = projectInfoMapper.ProjectNewByYear();
        for (RequireData requireData : list) {
          if (requireData.getDeptName()==null){
              requireData.setDeptName("云网公司");
          }
        }
        return list;
    }


    /**
     * 在建重大项目
     */
    @Override
    public List<RequireData> ProjectIsByYear() {
        List<RequireData> list = projectInfoMapper.ProjectIsByYear();
        for (RequireData requireData : list) {
            if (requireData.getDeptName()==null){
                requireData.setDeptName("云网公司");
            }
        }
        return list;
    }

    /**
     * 单位基本情况本年
     */
    @Override
    public List<DeptBasicInfo> DeptInfo() {
//        创建空集合，用于返回数据
        List<DeptBasicInfo> list = projectInfoMapper.getDeptName();
//        获取单位名称，立项项目数，立项项目金额
        List<DeptBasicInfo> list1 = projectInfoMapper.getLXInfo();
//        获取单位名称，项目关闭数，项目关闭金额
        List<DeptBasicInfo> list2 = projectInfoMapper.getGBInfo();
//        获取单位名称，收入确认额
        List<DeptBasicInfo> list3 = projectInfoMapper.getSRQRInfo();
//        获取单位名称，收票金额
        List<DeptBasicInfo> list4 = projectInfoMapper.getSPInfo();
//        获取单位名称，开票金额
        List<DeptBasicInfo> list5 = projectInfoMapper.getKPInfo();
        if (list != null) {
            for (DeptBasicInfo deptBasicInfo : list) {
//            添加立项项目数，立项项目金额
                for (DeptBasicInfo basicInfo : list1) {
                    if (basicInfo.getDeptName().equals(deptBasicInfo.getDeptName())) {
                        deptBasicInfo.setLXNumer(basicInfo.getLXNumer());
                        deptBasicInfo.setLXMoney(basicInfo.getLXMoney());
                    }
                }
//            添加项目关闭数，项目关闭金额
                for (DeptBasicInfo basicInfo : list2) {
                    if (basicInfo.getDeptName().equals(deptBasicInfo.getDeptName())) {
                        deptBasicInfo.setGBNumber(basicInfo.getGBNumber());
                        deptBasicInfo.setGBMoney(basicInfo.getGBMoney());
                    }
                }
//            添加收入确认额
                for (DeptBasicInfo basicInfo : list3) {
                    if (basicInfo.getDeptName().equals(deptBasicInfo.getDeptName())) {
                        deptBasicInfo.setSRQRMoney(basicInfo.getSRQRMoney());
                    }
                }
//        添加收票金额
                for (DeptBasicInfo basicInfo : list4) {
                    if (basicInfo.getDeptName().equals(deptBasicInfo.getDeptName())) {
                        deptBasicInfo.setSPMoney(basicInfo.getSPMoney());
                    }
                }
//        添加开票金额
                for (DeptBasicInfo basicInfo : list5) {
                    if (basicInfo.getDeptName().equals(deptBasicInfo.getDeptName())) {
                        deptBasicInfo.setKPMoney(basicInfo.getKPMoney());
                    }
                }
            }
        }
//        进行数据封装
        for (DeptBasicInfo deptBasicInfo : list) {
//            对对象进行优化处理
            if (deptBasicInfo.getLXNumer() == null) {
                deptBasicInfo.setLXNumer(0L);
            }
            if (deptBasicInfo.getLXMoney() == null) {
                deptBasicInfo.setLXMoney(0L);
            }
            if (deptBasicInfo.getGBNumber() == null) {
                deptBasicInfo.setGBNumber(0L);
            }
            if (deptBasicInfo.getGBMoney() == null) {
                deptBasicInfo.setGBMoney(0L);
            }
            if (deptBasicInfo.getSRQRMoney() == null) {
                deptBasicInfo.setSRQRMoney(0L);
            }
            if (deptBasicInfo.getSPMoney() == null) {
                deptBasicInfo.setSPMoney(0L);
            }
            if (deptBasicInfo.getKPMoney() == null) {
                deptBasicInfo.setKPMoney(0L);
            }
        }
        return list;
    }



    /**
     * 单位基本情况本月
     */
    @Override
    public List<DeptBasicInfo> DeptInfoByMonth() {
//        创建空集合，用于返回数据
        List<DeptBasicInfo> list = projectInfoMapper.getDeptName();
//        获取单位名称，立项项目数，立项项目金额
        List<DeptBasicInfo> list1 = projectInfoMapper.getLXInfoByMonth();
//        获取单位名称，项目关闭数，项目关闭金额
        List<DeptBasicInfo> list2 = projectInfoMapper.getGBInfoByMonth();
//        获取单位名称，收入确认额
        List<DeptBasicInfo> list3 = projectInfoMapper.getSRQRInfoByMonth();
//        获取单位名称，收票金额
        List<DeptBasicInfo> list4 = projectInfoMapper.getSPInfoByMonth();
//        获取单位名称，开票金额
        List<DeptBasicInfo> list5 = projectInfoMapper.getKPInfoByMonth();
        if (list != null) {
            for (DeptBasicInfo deptBasicInfo : list) {
//            添加立项项目数，立项项目金额
                for (DeptBasicInfo basicInfo : list1) {
                    if (basicInfo.getDeptName().equals(deptBasicInfo.getDeptName())) {
                        deptBasicInfo.setLXNumer(basicInfo.getLXNumer());
                        deptBasicInfo.setLXMoney(basicInfo.getLXMoney());
                    }
                }
//            添加项目关闭数，项目关闭金额
                for (DeptBasicInfo basicInfo : list2) {
                    if (basicInfo.getDeptName().equals(deptBasicInfo.getDeptName())) {
                        deptBasicInfo.setGBNumber(basicInfo.getGBNumber());
                        deptBasicInfo.setGBMoney(basicInfo.getGBMoney());
                    }
                }
//            添加收入确认额
                for (DeptBasicInfo basicInfo : list3) {
                    if (basicInfo.getDeptName().equals(deptBasicInfo.getDeptName())) {
                        deptBasicInfo.setSRQRMoney(basicInfo.getSRQRMoney());
                    }
                }
//        添加收票金额
                for (DeptBasicInfo basicInfo : list4) {
                    if (basicInfo.getDeptName().equals(deptBasicInfo.getDeptName())) {
                        deptBasicInfo.setSPMoney(basicInfo.getSPMoney());
                    }
                }
//        添加开票金额
                for (DeptBasicInfo basicInfo : list5) {
                    if (basicInfo.getDeptName().equals(deptBasicInfo.getDeptName())) {
                        deptBasicInfo.setKPMoney(basicInfo.getKPMoney());
                    }
                }
            }
        }
//        进行数据封装
        for (DeptBasicInfo deptBasicInfo : list) {
//            对对象进行优化处理
            if (deptBasicInfo.getLXNumer() == null) {
                deptBasicInfo.setLXNumer(0L);
            }
            if (deptBasicInfo.getLXMoney() == null) {
                deptBasicInfo.setLXMoney(0L);
            }
            if (deptBasicInfo.getGBNumber() == null) {
                deptBasicInfo.setGBNumber(0L);
            }
            if (deptBasicInfo.getGBMoney() == null) {
                deptBasicInfo.setGBMoney(0L);
            }
            if (deptBasicInfo.getSRQRMoney() == null) {
                deptBasicInfo.setSRQRMoney(0L);
            }
            if (deptBasicInfo.getSPMoney() == null) {
                deptBasicInfo.setSPMoney(0L);
            }
            if (deptBasicInfo.getKPMoney() == null) {
                deptBasicInfo.setKPMoney(0L);
            }
        }
        return list;
    }


    /**
     * 单位基本情况本月(关于生命周期)
     */
    @Override
    public List<DeptLife> DeptProjectLife() {
//        获取生命周期数值
        List<DeptLife> list = projectInfoMapper.DeptProjectLife();
//         获取立项数量
        List<DeptLife> list3 = projectInfoMapper.DeptLXProjectLife();
//        获取本年在建数量和金额
        List<DeptLife> list1 = projectInfoMapper.DeptProjectIsBuilding();
//        获取关闭数量和金额
        List<DeptLife> list2 = projectInfoMapper.DeptProjectClosed();
        for (DeptLife deptLife : list) {
//            填充本年在建数量和金额
            for (DeptLife life : list1) {
                if (life.getDeptName().equals(deptLife.getDeptName())) {
                    deptLife.setNumberIsProject(life.getNumberIsProject());
                    deptLife.setMoneyIsProject(life.getMoneyIsProject());
                }
            }
//            填充关闭数量和金额
            for (DeptLife life : list2) {
                if (life.getDeptName().equals(deptLife.getDeptName())) {
                    deptLife.setNumberProjectFinish(life.getNumberProjectFinish());
                    deptLife.setMoneyProjectFinish(life.getMoneyProjectFinish());
                }
            }
//            填充立项数量
            for (DeptLife life : list3) {
                if (life.getDeptName().equals(deptLife.getDeptName())) {
                    deptLife.setLXProject(life.getLXProject());
                }
            }
            if (deptLife.getProjectLifeNumber1() == null) {
                deptLife.setProjectLifeNumber1(0L);
            }
            if (deptLife.getProjectLifeNumber2() == null) {
                deptLife.setProjectLifeNumber2(0L);
            }
            if (deptLife.getProjectLifeNumber3() == null) {
                deptLife.setProjectLifeNumber3(0L);
            }
            if (deptLife.getProjectLifeNumber4() == null) {
                deptLife.setProjectLifeNumber4(0L);
            }
            if (deptLife.getProjectLifeNumber5() == null) {
                deptLife.setProjectLifeNumber5(0L);
            }
            if (deptLife.getNumberIsProject() == null) {
                deptLife.setNumberIsProject(0L);
            }
            if (deptLife.getMoneyIsProject() == null) {
                deptLife.setMoneyIsProject(0L);
            }
            if (deptLife.getNumberProjectFinish() == null) {
                deptLife.setNumberProjectFinish(0);
            }
            if (deptLife.getMoneyProjectFinish() == null) {
                deptLife.setMoneyProjectFinish(0L);
            }
            if (deptLife.getLXProject() == null) {
                deptLife.setLXProject(0);
            }
        }
        return list;
    }

    /**
     * 单位全年收票
     */
    @Override
    public List<DeptLife> ProjectCost() {
        List<DeptLife> list = projectInfoMapper.ProjectCost();
        return list;
    }

    /**
     * 单位本月收票
     */
    @Override
    public List<DeptLife> ProjectCostByMonth() {
        List<DeptLife> list = projectInfoMapper.ProjectCostByMonth();
        return list;
    }

    /**
     * 单位全年开票
     */
    @Override
    public List<DeptLife> ProjectIncome() {
        List<DeptLife> list = projectInfoMapper.ProjectIncome();
        return list;
    }

    /**
     * 单位本月开票
     */
    @Override
    public List<DeptLife> ProjectIncomeByMonth() {
        List<DeptLife> list = projectInfoMapper.ProjectIncomeByMonth();
        return list;
    }


    /**
     * 新建项目三级菜单
     */
    @Override
    public List<ProjectNew> ProjectNewInfo(PageVo pageVo) {
        int pageSize = pageVo.getPageSize();
        int pageNumber = (pageVo.getPageNumber() - 1) * pageSize;
        List<ProjectNew> list1 = projectInfoMapper.ProjectNewInfo();
        List<ProjectNew> list = projectInfoMapper.ProjectNewInfo1(pageNumber, pageSize);
        for (ProjectNew projectNew : list) {
            projectNew.setTotal(list1.size());
        }
        return list;
    }

    /**
     * 在建项目三级菜单
     */
    @Override
    public List<ProjectNew> ProjectIsInfo(PageVo pageVo) {
        int pageSize = pageVo.getPageSize();
        int pageNumber = (pageVo.getPageNumber() - 1) * pageSize;
        List<ProjectNew> list1 = projectInfoMapper.ProjectIsInfo();
        List<ProjectNew> list = projectInfoMapper.ProjectIsInfo1(pageNumber, pageSize);
        for (ProjectNew projectNew : list) {
            projectNew.setTotal(list1.size());
        }
        return list;
    }

    /**
     * 在建项目and项目、单位名称模糊查询
     */
    @Override
    public List<ProjectNew> ProjectIsInfoLikeProjectNumber(ProjectNew projectNew) {
        List<ProjectNew> projectNews = projectInfoMapper.ProjectIsInfoLikeProjectNumber(projectNew);
        return projectNews;
    }


    /**
     * 数量金额二级菜单
     */
    @Override
    public List<NumberAndMoneyTwice> NumberAndMoneyTwice(NumberAndMoneyTwice numberAndMoneyTwice1) {
//        查询出所有部门
        List<NumberAndMoneyTwice> list = projectInfoMapper.selectDeptName();
//        添加立项数，立项金额
        List<NumberAndMoneyTwice> list1 = projectInfoMapper.getLXNumberAndMoneyTwice();
//        添加关闭数，关闭金额
        List<NumberAndMoneyTwice> list2 = projectInfoMapper.getGBNumberAndMoneyTwice();
//        添加在建数，在建金额
        List<DeptLife> list3 = projectInfoMapper.DeptProjectIsBuilding();
//       获取在建工期长短数量
        List<DeptLife> list4 = projectInfoMapper.DeptProjectLife();
//        进行数据填充
        for (NumberAndMoneyTwice numberAndMoneyTwice : list) {
//            填充立项数,立项金额
            for (NumberAndMoneyTwice andMoneyTwice : list1) {
                if (andMoneyTwice.getDeptName().equals(numberAndMoneyTwice.getDeptName())) {
                    numberAndMoneyTwice.setLXNumeber(andMoneyTwice.getLXNumeber());
                    numberAndMoneyTwice.setLXMoney(andMoneyTwice.getLXMoney());
                }
            }
//            填充关闭数，关闭金额
            for (NumberAndMoneyTwice andMoneyTwice : list2) {
                if (andMoneyTwice.getDeptName().equals(numberAndMoneyTwice.getDeptName())) {
                    numberAndMoneyTwice.setGBNumber(andMoneyTwice.getGBNumber());
                    numberAndMoneyTwice.setGBMoney(andMoneyTwice.getGBMoney());
                }
            }
//            填充在建数，在建金额
            for (DeptLife deptLife : list3) {
                if (deptLife.getDeptName().equals(numberAndMoneyTwice.getDeptName())) {
                    numberAndMoneyTwice.setZJNumber(deptLife.getNumberIsProject());
                    numberAndMoneyTwice.setZJMoney(deptLife.getMoneyIsProject());
                }
            }
//            填充在线周期
            for (DeptLife deptLife : list4) {
                if (deptLife.getDeptName().equals(numberAndMoneyTwice.getDeptName())) {
                    numberAndMoneyTwice.setProjectLifeNumber1(deptLife.getProjectLifeNumber1());
                    numberAndMoneyTwice.setProjectLifeNumber2(deptLife.getProjectLifeNumber2());
                    numberAndMoneyTwice.setProjectLifeNumber3(deptLife.getProjectLifeNumber3());
                    numberAndMoneyTwice.setProjectLifeNumber4(deptLife.getProjectLifeNumber4());
                    numberAndMoneyTwice.setProjectLifeNumber5(deptLife.getProjectLifeNumber5());
                }
            }
//            对数据进行修改
            if (numberAndMoneyTwice.getLXNumeber() == null) {
                numberAndMoneyTwice.setLXNumeber(0L);
            }
            if (numberAndMoneyTwice.getLXMoney() == null) {
                numberAndMoneyTwice.setLXMoney(0L);
            }
            if (numberAndMoneyTwice.getGBNumber() == null) {
                numberAndMoneyTwice.setGBNumber(0L);
            }
            if (numberAndMoneyTwice.getGBMoney() == null) {
                numberAndMoneyTwice.setGBMoney(0L);
            }
            if (numberAndMoneyTwice.getZJNumber() == null) {
                numberAndMoneyTwice.setZJNumber(0L);
            }
            if (numberAndMoneyTwice.getZJMoney() == null) {
                numberAndMoneyTwice.setZJMoney(0L);
            }
            if (numberAndMoneyTwice.getProjectLifeNumber1() == null) {
                numberAndMoneyTwice.setProjectLifeNumber1(0L);
            }
            if (numberAndMoneyTwice.getProjectLifeNumber2() == null) {
                numberAndMoneyTwice.setProjectLifeNumber2(0L);
            }
            if (numberAndMoneyTwice.getProjectLifeNumber3() == null) {
                numberAndMoneyTwice.setProjectLifeNumber3(0L);
            }
            if (numberAndMoneyTwice.getProjectLifeNumber4() == null) {
                numberAndMoneyTwice.setProjectLifeNumber4(0L);
            }
            if (numberAndMoneyTwice.getProjectLifeNumber5() == null) {
                numberAndMoneyTwice.setProjectLifeNumber5(0L);
            }
        }
//        根据传进来的状态去判断 排序
        if (numberAndMoneyTwice1.getType() != null) {
            if (numberAndMoneyTwice1.getType() == 1) {
                List<NumberAndMoneyTwice> collect = list.stream()
                        .sorted(Comparator.comparing(NumberAndMoneyTwice::getLXMoney).reversed())
                        .collect(Collectors.toList());
                return collect;
            } else if (numberAndMoneyTwice1.getType() == 2) {
                List<NumberAndMoneyTwice> collect = list.stream()
                        .sorted(Comparator.comparing(NumberAndMoneyTwice::getZJMoney).reversed())
                        .collect(Collectors.toList());
                return collect;
            } else if (numberAndMoneyTwice1.getType() == 3) {
                List<NumberAndMoneyTwice> collect = list.stream()
                        .sorted(Comparator.comparing(NumberAndMoneyTwice::getGBMoney).reversed())
                        .collect(Collectors.toList());
                return collect;
            }
        }
        return list;
    }

    @Override
    public List<NumberAndMoneyTwice> NumberAndMoneyTwiceByMonth(NumberAndMoneyTwice numberAndMoneyTwice1) {
        //        查询出所有部门
        List<NumberAndMoneyTwice> list = projectInfoMapper.selectDeptName();
//        添加立项数，立项金额
        List<NumberAndMoneyTwice> list1 = projectInfoMapper.getLXNumberAndMoneyTwiceByMonth();
//        添加关闭数，关闭金额
        List<NumberAndMoneyTwice> list2 = projectInfoMapper.getGBNumberAndMoneyTwiceByMonth();
//        添加在建数，在建金额
        List<DeptLife> list3 = projectInfoMapper.DeptProjectIsBuilding();
//       获取在建工期长短数量
        List<DeptLife> list4 = projectInfoMapper.DeptProjectLife();
//        进行数据填充
        for (NumberAndMoneyTwice numberAndMoneyTwice : list) {
//            填充立项数,立项金额
            for (NumberAndMoneyTwice andMoneyTwice : list1) {
                if (andMoneyTwice.getDeptName().equals(numberAndMoneyTwice.getDeptName())) {
                    numberAndMoneyTwice.setLXNumeber(andMoneyTwice.getLXNumeber());
                    numberAndMoneyTwice.setLXMoney(andMoneyTwice.getLXMoney());
                }
            }
//            填充关闭数，关闭金额
            for (NumberAndMoneyTwice andMoneyTwice : list2) {
                if (andMoneyTwice.getDeptName().equals(numberAndMoneyTwice.getDeptName())) {
                    numberAndMoneyTwice.setGBNumber(andMoneyTwice.getGBNumber());
                    numberAndMoneyTwice.setGBMoney(andMoneyTwice.getGBMoney());
                }
            }
//            填充在建数，在建金额
            for (DeptLife deptLife : list3) {
                if (deptLife.getDeptName().equals(numberAndMoneyTwice.getDeptName())) {
                    numberAndMoneyTwice.setZJNumber(deptLife.getNumberIsProject());
                    numberAndMoneyTwice.setZJMoney(deptLife.getMoneyIsProject());
                }
            }
//            填充在线周期
            for (DeptLife deptLife : list4) {
                if (deptLife.getDeptName().equals(numberAndMoneyTwice.getDeptName())) {
                    numberAndMoneyTwice.setProjectLifeNumber1(deptLife.getProjectLifeNumber1());
                    numberAndMoneyTwice.setProjectLifeNumber2(deptLife.getProjectLifeNumber2());
                    numberAndMoneyTwice.setProjectLifeNumber3(deptLife.getProjectLifeNumber3());
                    numberAndMoneyTwice.setProjectLifeNumber4(deptLife.getProjectLifeNumber4());
                    numberAndMoneyTwice.setProjectLifeNumber5(deptLife.getProjectLifeNumber5());
                }
            }
//            对数据进行修改
            if (numberAndMoneyTwice.getLXNumeber() == null) {
                numberAndMoneyTwice.setLXNumeber(0L);
            }
            if (numberAndMoneyTwice.getLXMoney() == null) {
                numberAndMoneyTwice.setLXMoney(0L);
            }
            if (numberAndMoneyTwice.getGBNumber() == null) {
                numberAndMoneyTwice.setGBNumber(0L);
            }
            if (numberAndMoneyTwice.getGBMoney() == null) {
                numberAndMoneyTwice.setGBMoney(0L);
            }
            if (numberAndMoneyTwice.getZJNumber() == null) {
                numberAndMoneyTwice.setZJNumber(0L);
            }
            if (numberAndMoneyTwice.getZJMoney() == null) {
                numberAndMoneyTwice.setZJMoney(0L);
            }
            if (numberAndMoneyTwice.getProjectLifeNumber1() == null) {
                numberAndMoneyTwice.setProjectLifeNumber1(0L);
            }
            if (numberAndMoneyTwice.getProjectLifeNumber2() == null) {
                numberAndMoneyTwice.setProjectLifeNumber2(0L);
            }
            if (numberAndMoneyTwice.getProjectLifeNumber3() == null) {
                numberAndMoneyTwice.setProjectLifeNumber3(0L);
            }
            if (numberAndMoneyTwice.getProjectLifeNumber4() == null) {
                numberAndMoneyTwice.setProjectLifeNumber4(0L);
            }
            if (numberAndMoneyTwice.getProjectLifeNumber5() == null) {
                numberAndMoneyTwice.setProjectLifeNumber5(0L);
            }
        }
        //        根据传进来的状态去判断 排序
        if (numberAndMoneyTwice1.getType() != null) {
            if (numberAndMoneyTwice1.getType() == 1) {
                List<NumberAndMoneyTwice> collect = list.stream()
                        .sorted(Comparator.comparing(NumberAndMoneyTwice::getLXMoney).reversed())
                        .collect(Collectors.toList());
                return collect;
            } else if (numberAndMoneyTwice1.getType() == 2) {
                List<NumberAndMoneyTwice> collect = list.stream()
                        .sorted(Comparator.comparing(NumberAndMoneyTwice::getZJMoney).reversed())
                        .collect(Collectors.toList());
                return collect;
            } else if (numberAndMoneyTwice1.getType() == 3) {
                List<NumberAndMoneyTwice> collect = list.stream()
                        .sorted(Comparator.comparing(NumberAndMoneyTwice::getGBMoney).reversed())
                        .collect(Collectors.toList());
                return collect;
            }
        }
        return list;
    }

    @Override
    public List<NumberAndMoneyTwice> NumberAndMoneyTwiceClose(NumberAndMoneyTwice numberAndMoneyTwice1) {
        //        查询出所有部门
        List<NumberAndMoneyTwice> list = projectInfoMapper.selectDeptName();
//        添加立项数，立项金额
        List<NumberAndMoneyTwice> list1 = projectInfoMapper.getLXNumberAndMoneyTwiceByMonth();
//        添加关闭数，关闭金额
        List<NumberAndMoneyTwice> list2 = projectInfoMapper.getGBNumberAndMoneyTwiceByMonth();
//        添加在建数，在建金额
        List<DeptLife> list3 = projectInfoMapper.DeptProjectIsBuilding();
//       获取在建工期长短数量
        List<DeptLife> list4 = projectInfoMapper.DeptProjectLifeClose();
//        进行数据填充
        for (NumberAndMoneyTwice numberAndMoneyTwice : list) {
//            填充立项数,立项金额
            for (NumberAndMoneyTwice andMoneyTwice : list1) {
                if (andMoneyTwice.getDeptName().equals(numberAndMoneyTwice.getDeptName())) {
                    numberAndMoneyTwice.setLXNumeber(andMoneyTwice.getLXNumeber());
                    numberAndMoneyTwice.setLXMoney(andMoneyTwice.getLXMoney());
                }
            }
//            填充关闭数，关闭金额
            for (NumberAndMoneyTwice andMoneyTwice : list2) {
                if (andMoneyTwice.getDeptName().equals(numberAndMoneyTwice.getDeptName())) {
                    numberAndMoneyTwice.setGBNumber(andMoneyTwice.getGBNumber());
                    numberAndMoneyTwice.setGBMoney(andMoneyTwice.getGBMoney());
                }
            }
//            填充在线周期
            for (DeptLife deptLife : list4) {
                if (deptLife.getDeptName().equals(numberAndMoneyTwice.getDeptName())) {
                    numberAndMoneyTwice.setProjectLifeNumber1(deptLife.getProjectLifeNumber1());
                    numberAndMoneyTwice.setProjectLifeNumber2(deptLife.getProjectLifeNumber2());
                    numberAndMoneyTwice.setProjectLifeNumber3(deptLife.getProjectLifeNumber3());
                    numberAndMoneyTwice.setProjectLifeNumber4(deptLife.getProjectLifeNumber4());
                    numberAndMoneyTwice.setProjectLifeNumber5(deptLife.getProjectLifeNumber5());
                }
            }
//            对数据进行修改
            if (numberAndMoneyTwice.getLXNumeber() == null) {
                numberAndMoneyTwice.setLXNumeber(0L);
            }
            if (numberAndMoneyTwice.getLXMoney() == null) {
                numberAndMoneyTwice.setLXMoney(0L);
            }
            if (numberAndMoneyTwice.getGBNumber() == null) {
                numberAndMoneyTwice.setGBNumber(0L);
            }
            if (numberAndMoneyTwice.getGBMoney() == null) {
                numberAndMoneyTwice.setGBMoney(0L);
            }
            if (numberAndMoneyTwice.getProjectLifeNumber1() == null) {
                numberAndMoneyTwice.setProjectLifeNumber1(0L);
            }
            if (numberAndMoneyTwice.getProjectLifeNumber2() == null) {
                numberAndMoneyTwice.setProjectLifeNumber2(0L);
            }
            if (numberAndMoneyTwice.getProjectLifeNumber3() == null) {
                numberAndMoneyTwice.setProjectLifeNumber3(0L);
            }
            if (numberAndMoneyTwice.getProjectLifeNumber4() == null) {
                numberAndMoneyTwice.setProjectLifeNumber4(0L);
            }
            if (numberAndMoneyTwice.getProjectLifeNumber5() == null) {
                numberAndMoneyTwice.setProjectLifeNumber5(0L);
            }
        }
        //        根据传进来的状态去判断 排序
        if (numberAndMoneyTwice1.getType() != null) {
            if (numberAndMoneyTwice1.getType() == 1) {
                List<NumberAndMoneyTwice> collect = list.stream()
                        .sorted(Comparator.comparing(NumberAndMoneyTwice::getLXMoney).reversed())
                        .collect(Collectors.toList());
                return collect;
            } else if (numberAndMoneyTwice1.getType() == 2) {
                List<NumberAndMoneyTwice> collect = list.stream()
                        .sorted(Comparator.comparing(NumberAndMoneyTwice::getZJMoney).reversed())
                        .collect(Collectors.toList());
                return collect;
            } else if (numberAndMoneyTwice1.getType() == 3) {
                List<NumberAndMoneyTwice> collect = list.stream()
                        .sorted(Comparator.comparing(NumberAndMoneyTwice::getGBMoney).reversed())
                        .collect(Collectors.toList());
                return collect;
            }
        }
        return list;
    }

    @Override
    public List<NumberAndMoneyTwice> NumberAndMoneyTwiceByMonthClose(NumberAndMoneyTwice numberAndMoneyTwice1) {
        //        查询出所有部门
        List<NumberAndMoneyTwice> list = projectInfoMapper.selectDeptName();
//        添加立项数，立项金额
        List<NumberAndMoneyTwice> list1 = projectInfoMapper.getLXNumberAndMoneyTwiceByMonth();
//        添加关闭数，关闭金额
        List<NumberAndMoneyTwice> list2 = projectInfoMapper.getGBNumberAndMoneyTwiceByMonth();
//       获取关闭工期长短数量
        List<DeptLife> list4 = projectInfoMapper.DeptProjectLifeClose();
//        进行数据填充
        for (NumberAndMoneyTwice numberAndMoneyTwice : list) {
//            填充立项数,立项金额
            for (NumberAndMoneyTwice andMoneyTwice : list1) {
                if (andMoneyTwice.getDeptName().equals(numberAndMoneyTwice.getDeptName())) {
                    numberAndMoneyTwice.setLXNumeber(andMoneyTwice.getLXNumeber());
                    numberAndMoneyTwice.setLXMoney(andMoneyTwice.getLXMoney());
                }
            }
//            填充关闭数，关闭金额
            for (NumberAndMoneyTwice andMoneyTwice : list2) {
                if (andMoneyTwice.getDeptName().equals(numberAndMoneyTwice.getDeptName())) {
                    numberAndMoneyTwice.setGBNumber(andMoneyTwice.getGBNumber());
                    numberAndMoneyTwice.setGBMoney(andMoneyTwice.getGBMoney());
                }
            }
//            填充在线周期
            for (DeptLife deptLife : list4) {
                if (deptLife.getDeptName().equals(numberAndMoneyTwice.getDeptName())) {
                    numberAndMoneyTwice.setProjectLifeNumber1(deptLife.getProjectLifeNumber1());
                    numberAndMoneyTwice.setProjectLifeNumber2(deptLife.getProjectLifeNumber2());
                    numberAndMoneyTwice.setProjectLifeNumber3(deptLife.getProjectLifeNumber3());
                    numberAndMoneyTwice.setProjectLifeNumber4(deptLife.getProjectLifeNumber4());
                    numberAndMoneyTwice.setProjectLifeNumber5(deptLife.getProjectLifeNumber5());
                }
            }
//            对数据进行修改
            if (numberAndMoneyTwice.getLXNumeber() == null) {
                numberAndMoneyTwice.setLXNumeber(0L);
            }
            if (numberAndMoneyTwice.getLXMoney() == null) {
                numberAndMoneyTwice.setLXMoney(0L);
            }
            if (numberAndMoneyTwice.getGBNumber() == null) {
                numberAndMoneyTwice.setGBNumber(0L);
            }
            if (numberAndMoneyTwice.getGBMoney() == null) {
                numberAndMoneyTwice.setGBMoney(0L);
            }
            if (numberAndMoneyTwice.getProjectLifeNumber1() == null) {
                numberAndMoneyTwice.setProjectLifeNumber1(0L);
            }
            if (numberAndMoneyTwice.getProjectLifeNumber2() == null) {
                numberAndMoneyTwice.setProjectLifeNumber2(0L);
            }
            if (numberAndMoneyTwice.getProjectLifeNumber3() == null) {
                numberAndMoneyTwice.setProjectLifeNumber3(0L);
            }
            if (numberAndMoneyTwice.getProjectLifeNumber4() == null) {
                numberAndMoneyTwice.setProjectLifeNumber4(0L);
            }
            if (numberAndMoneyTwice.getProjectLifeNumber5() == null) {
                numberAndMoneyTwice.setProjectLifeNumber5(0L);
            }
        }
        //        根据传进来的状态去判断 排序
        if (numberAndMoneyTwice1.getType() != null) {
            if (numberAndMoneyTwice1.getType() == 1) {
                List<NumberAndMoneyTwice> collect = list.stream()
                        .sorted(Comparator.comparing(NumberAndMoneyTwice::getLXMoney).reversed())
                        .collect(Collectors.toList());
                return collect;
            } else if (numberAndMoneyTwice1.getType() == 2) {
                List<NumberAndMoneyTwice> collect = list.stream()
                        .sorted(Comparator.comparing(NumberAndMoneyTwice::getZJMoney).reversed())
                        .collect(Collectors.toList());
                return collect;
            } else if (numberAndMoneyTwice1.getType() == 3) {
                List<NumberAndMoneyTwice> collect = list.stream()
                        .sorted(Comparator.comparing(NumberAndMoneyTwice::getGBMoney).reversed())
                        .collect(Collectors.toList());
                return collect;
            }
        }
        return list;
    }


    /**
     * 收票跳转二级菜单
     */
    @Override
    public List<NumberAndMoneyTwice> SPMoneyTwice(PageVo pageVo) {
        int pageSize = pageVo.getPageSize();
        int pageNumber = (pageVo.getPageNumber() - 1) * pageSize;
        List<NumberAndMoneyTwice> list = projectInfoMapper.SPMoneyTwice();
        List<NumberAndMoneyTwice> list1 = projectInfoMapper.SPMoneyTwice1(pageNumber, pageSize);
        for (NumberAndMoneyTwice numberAndMoneyTwice : list1) {
            numberAndMoneyTwice.setTotal(list.size());
        }
        return list1;
    }

    /**
     * 收票跳转二级菜单本月
     */
    @Override
    public List<NumberAndMoneyTwice> SPMoneyTwiceByMonth(PageVo pageVo) {
        int pageSize = pageVo.getPageSize();
        int pageNumber = (pageVo.getPageNumber() - 1) * pageSize;
        List<NumberAndMoneyTwice> list = projectInfoMapper.SPMoneyTwiceByMonth();
        List<NumberAndMoneyTwice> list1 = projectInfoMapper.SPMoneyTwiceByMonth1(pageNumber, pageSize);
        for (NumberAndMoneyTwice numberAndMoneyTwice : list1) {
            numberAndMoneyTwice.setTotal(list.size());
        }
        return list1;
    }

    /**
     * 开票跳转二级菜单
     */
    @Override
    public List<NumberAndMoneyTwice> KPMoneyTwice(PageVo pageVo) {
        int pageSize = pageVo.getPageSize();
        int pageNumber = (pageVo.getPageNumber() - 1) * pageSize;
        List<NumberAndMoneyTwice> list = projectInfoMapper.KPMoneyTwice();
        List<NumberAndMoneyTwice> list1 = projectInfoMapper.KPMoneyTwice1(pageNumber, pageSize);
        for (NumberAndMoneyTwice numberAndMoneyTwice : list1) {
            numberAndMoneyTwice.setTotal(list.size());
        }
        return list1;
    }

    /**
     * 开票跳转二级菜单本月
     */
    @Override
    public List<NumberAndMoneyTwice> KPMoneyTwiceByMonth(PageVo pageVo) {
        int pageSize = pageVo.getPageSize();
        int pageNumber = (pageVo.getPageNumber() - 1) * pageSize;
        List<NumberAndMoneyTwice> list = projectInfoMapper.KPMoneyTwiceByMonth();
        List<NumberAndMoneyTwice> list1 = projectInfoMapper.KPMoneyTwiceByMonth1(pageNumber, pageSize);
        for (NumberAndMoneyTwice numberAndMoneyTwice : list1) {
            numberAndMoneyTwice.setTotal(list.size());
        }
        return list1;
    }


    /**
     * 立项项目详情三级菜单
     */
    @Override
    public List<NumberAndMoneyTwice> LXProjectInfoThird(RequestData requestData, PageVo pageVo) {
//        得到单位名称
        String time = requestData.getTime();
        String deptName1 = requestData.getDeptName();
        String deptName = deptName1.substring(0, 2);
        int pageSize = pageVo.getPageSize();
        int pageNumber = (pageVo.getPageNumber() - 1) * pageSize;
//        放入请求
        if (time.equals("本年")) {
            List<NumberAndMoneyTwice> list = projectInfoMapper.LXProjectInfoThird(deptName);
            List<NumberAndMoneyTwice> list1 = projectInfoMapper.LXProjectInfoThird1(deptName, pageNumber, pageSize);
            for (NumberAndMoneyTwice numberAndMoneyTwice : list1) {
                if (list.size() == 0) {
                    numberAndMoneyTwice.setTotal(0);
                } else {
                    numberAndMoneyTwice.setTotal(list.size());
                }

            }
            return list1;
        } else {
            List<NumberAndMoneyTwice> list = projectInfoMapper.LXProjectInfoThirdByMonth(deptName);
            List<NumberAndMoneyTwice> list1 = projectInfoMapper.LXProjectInfoThirdByMonth1(deptName, pageNumber, pageSize);
            for (NumberAndMoneyTwice numberAndMoneyTwice : list1) {
                if (list.size() == 0) {
                    numberAndMoneyTwice.setTotal(0);
                } else {
                    numberAndMoneyTwice.setTotal(list.size());
                }
            }
            return list1;
        }
    }


    /**
     * 关闭项目详情三级菜单
     */
    @Override
    public List<NumberAndMoneyTwice> GBProjectInfoThird(RequestData requestData, PageVo pageVo) {
        //        得到单位名称
        String time = requestData.getTime();
        String deptName1 = requestData.getDeptName();
        String deptName = deptName1.substring(0, 2);
        int pageSize = pageVo.getPageSize();
        int pageNumber = (pageVo.getPageNumber() - 1) * pageSize;
//        放入请求
        if (time.equals("本年")) {
            List<NumberAndMoneyTwice> list = projectInfoMapper.GBProjectInfoThird(deptName);
            List<NumberAndMoneyTwice> list1 = projectInfoMapper.GBProjectInfoThird1(deptName, pageNumber, pageSize);
            for (NumberAndMoneyTwice numberAndMoneyTwice : list1) {
                if (list.size() == 0) {
                    numberAndMoneyTwice.setTotal(0);
                } else {
                    numberAndMoneyTwice.setTotal(list.size());
                }
            }
            return list1;
        } else {
            List<NumberAndMoneyTwice> list = projectInfoMapper.GBProjectInfoThirdByMonth(deptName);
            List<NumberAndMoneyTwice> list1 = projectInfoMapper.GBProjectInfoThirdByMonth1(deptName, pageNumber, pageSize);
            for (NumberAndMoneyTwice numberAndMoneyTwice : list1) {
                if (list.size() == 0) {
                    numberAndMoneyTwice.setTotal(0);
                } else {
                    numberAndMoneyTwice.setTotal(list.size());
                }
            }
            return list1;
        }
    }

    /**
     * 在建项目详情三级菜单
     */
    @Override
    public List<NumberAndMoneyTwice> ZJProjectInfoThird(RequestData requestData, PageVo pageVo) {
        //        得到单位名称
        String time = requestData.getTime();
        String deptName1 = requestData.getDeptName();
        String deptName = deptName1.substring(0, 2);
        int pageSize = pageVo.getPageSize();
        int pageNumber = (pageVo.getPageNumber() - 1) * pageSize;
        List<NumberAndMoneyTwice> list = projectInfoMapper.ZJProjectInfoThird(deptName);
        List<NumberAndMoneyTwice> list1 = projectInfoMapper.ZJProjectInfoThird1(deptName, pageNumber, pageSize);
        for (NumberAndMoneyTwice numberAndMoneyTwice : list1) {
            if (list.size() == 0) {
                numberAndMoneyTwice.setTotal(0);
            } else {
                numberAndMoneyTwice.setTotal(list.size());
            }
        }
        return list1;
    }

    /**
     * 已开工半年项目详情三级菜单
     */
    @Override
    public List<NumberAndMoneyTwice> BNProjectInfoThird(RequestData requestData, PageVo pageVo) {
        //        得到单位名称
        String time = requestData.getTime();
        String deptName1 = requestData.getDeptName();
        String deptName = deptName1.substring(0, 2);
        int pageSize = pageVo.getPageSize();
        int pageNumber = (pageVo.getPageNumber() - 1) * pageSize;
        List<NumberAndMoneyTwice> list = projectInfoMapper.BNProjectInfoThird(deptName);
        List<NumberAndMoneyTwice> list1 = projectInfoMapper.BNProjectInfoThird1(deptName, pageNumber, pageSize);
        for (NumberAndMoneyTwice numberAndMoneyTwice : list1) {
            if (list.size() == 0) {
                numberAndMoneyTwice.setTotal(0);
            } else {
                numberAndMoneyTwice.setTotal(list.size());
            }
        }
        return list1;
    }

    /**
     * 已开工半年到一年项目详情三级菜单
     */
    @Override
    public List<NumberAndMoneyTwice> BNDYNProjectInfoThird(RequestData requestData, PageVo pageVo) {
        //        得到单位名称
        String time = requestData.getTime();
        String deptName1 = requestData.getDeptName();
        String deptName = deptName1.substring(0, 2);
        int pageSize = pageVo.getPageSize();
        int pageNumber = (pageVo.getPageNumber() - 1) * pageSize;
        List<NumberAndMoneyTwice> list = projectInfoMapper.BNDYNProjectInfoThird(deptName);
        List<NumberAndMoneyTwice> list1 = projectInfoMapper.BNDYNProjectInfoThird1(deptName, pageNumber, pageSize);
        for (NumberAndMoneyTwice numberAndMoneyTwice : list1) {
            if (list.size() == 0) {
                numberAndMoneyTwice.setTotal(0);
            } else {
                numberAndMoneyTwice.setTotal(list.size());
            }
        }
        return list1;
    }

    /**
     * 已开工一年到两年项目详情三级菜单
     */
    @Override
    public List<NumberAndMoneyTwice> YNDLNProjectInfoThird(RequestData requestData, PageVo pageVo) {
        //        得到单位名称
        String time = requestData.getTime();
        String deptName1 = requestData.getDeptName();
        String deptName = deptName1.substring(0, 2);
        int pageSize = pageVo.getPageSize();
        int pageNumber = (pageVo.getPageNumber() - 1) * pageSize;
        List<NumberAndMoneyTwice> list = projectInfoMapper.YNDLNProjectInfoThird(deptName);
        List<NumberAndMoneyTwice> list1 = projectInfoMapper.YNDLNProjectInfoThird1(deptName, pageNumber, pageSize);
        for (NumberAndMoneyTwice numberAndMoneyTwice : list1) {
            if (list.size() == 0) {
                numberAndMoneyTwice.setTotal(0);
            } else {
                numberAndMoneyTwice.setTotal(list.size());
            }
        }
        return list1;
    }

    /**
     * 已开工两年到三年项目详情三级菜单
     */
    @Override
    public List<NumberAndMoneyTwice> LNDSNProjectInfoThird(RequestData requestData, PageVo pageVo) {
        //        得到单位名称
        String time = requestData.getTime();
        String deptName1 = requestData.getDeptName();
        String deptName = deptName1.substring(0, 2);
        int pageSize = pageVo.getPageSize();
        int pageNumber = (pageVo.getPageNumber() - 1) * pageSize;
        List<NumberAndMoneyTwice> list = projectInfoMapper.LNDSNProjectInfoThird(deptName);
        List<NumberAndMoneyTwice> list1 = projectInfoMapper.LNDSNProjectInfoThird1(deptName, pageNumber, pageSize);
        for (NumberAndMoneyTwice numberAndMoneyTwice : list1) {
            if (list.size() == 0) {
                numberAndMoneyTwice.setTotal(0);
            } else {
                numberAndMoneyTwice.setTotal(list.size());
            }
        }
        return list1;
    }

    /**
     * 已开工三年以上项目详情三级菜单
     */
    @Override
    public List<NumberAndMoneyTwice> SNYSProjectInfoThird(RequestData requestData, PageVo pageVo) {
        //        得到单位名称
        String time = requestData.getTime();
        String deptName1 = requestData.getDeptName();
        String deptName = deptName1.substring(0, 2);
        int pageSize = pageVo.getPageSize();
        int pageNumber = (pageVo.getPageNumber() - 1) * pageSize;
        List<NumberAndMoneyTwice> list = projectInfoMapper.SNYSProjectInfoThird(deptName);
        List<NumberAndMoneyTwice> list1 = projectInfoMapper.SNYSProjectInfoThird1(deptName, pageNumber, pageSize);
        for (NumberAndMoneyTwice numberAndMoneyTwice : list1) {
            if (list.size() == 0) {
                numberAndMoneyTwice.setTotal(0);
            } else {
                numberAndMoneyTwice.setTotal(list.size());
            }
        }
        return list1;
    }

    /**
     * 首页数据--开票金额和收入确认
     */
    @Override
    public DeptLife SYSJ() {
        DeptLife deptLife = projectInfoMapper.KPByMonth();
        DeptLife deptLife1 = projectInfoMapper.KPByYear();
        DeptLife deptLife2 = projectInfoMapper.SRQRByMonth();
        DeptLife deptLife3 = projectInfoMapper.SRQRByYear();
        deptLife.setKPMoneyByYear(deptLife1.getKPMoneyByYear());
        deptLife.setSRQRByMonth(deptLife2.getSRQRByMonth());
        deptLife.setSRQRByYear(deptLife3.getSRQRByYear());
        return deptLife;
    }


    /**
     * 首页数据--现金流入流出
     */
    @Override
    public DeptLife XJLRLC() {
        DeptLife deptLife = projectInfoMapper.XJLRYear();
        DeptLife deptLife1 = projectInfoMapper.XJLRMonth();
        DeptLife deptLife2 = projectInfoMapper.XJLCYear();
        DeptLife deptLife3 = projectInfoMapper.XJLCMonth();
        if (deptLife1.getXJLRMonth() != null) {
            deptLife.setXJLRMonth(deptLife1.getXJLRMonth());
        } else {
            deptLife.setXJLRMonth(0L);
        }
        if (deptLife2 != null) {
            deptLife.setXJLCYear(deptLife2.getXJLCYear());
        } else {
            deptLife.setXJLCYear(0L);
        }
        if (deptLife3 != null) {
            deptLife.setXJLCMonth(deptLife3.getXJLCMonth());
        } else {
            deptLife.setXJLCMonth(0L);
        }
        return deptLife;
    }

    /**
     * 首页数据--应收账款
     */
    @Override
    public AllBoardData YSZK() {
//        结算款
        AllBoardData allBoardData1 = projectInfoMapper.getYSZKJSK();
//        进度款
        AllBoardData allBoardData2 = projectInfoMapper.getYSZKJDK();
        if (allBoardData2 != null) {
            allBoardData1.setYSZKJDK(allBoardData2.getYSZKJDK());
        }
//        计算总额
        long l = allBoardData1.getYSZKJSK() + allBoardData1.getYSZKJDK();
        allBoardData1.setYSZKZE(l);
        return allBoardData1;
    }


    /**
     * 首页数据--所有数据集合
     */
    @Override
    public List<AllBoardData> SYData() {
//        得到所有单位名称
        List<AllBoardData> allBoardData = projectInfoMapper.selectDeptName1();
//        得到单位的投标数
        List<AllBoardData> allBoardData1 = projectInfoMapper.selectTBNumber();
//        得到单位的中标数
        List<AllBoardData> allBoardData2 = projectInfoMapper.selectZBNumber();
//        得到单位的现金流--流入金额
        List<AllBoardData> allBoardData3 = projectInfoMapper.GETXJLR();
//        得到单位的现金流--流出金额
        List<AllBoardData> allBoardData4 = projectInfoMapper.GETXJLC();
//        得到单位的合同签订金额
        List<AllBoardData> allBoardData5 = projectInfoMapper.selectHTQDMoney();
//        得到单位的收入确认金额
        List<AllBoardData> allBoardData6 = projectInfoMapper.GetSRQR();
//        得到单位的开票金额
        List<AllBoardData> allBoardData7 = projectInfoMapper.GetKP();
//        得到单位的项目情况--立项项目
        List<AllBoardData> allBoardData8 = projectInfoMapper.GetLXNum();
//        得到单位的项目情况--关闭项目
        List<AllBoardData> allBoardData9 = projectInfoMapper.GetGBNum();
//        得到单位的应收账款--应收账款结算款
        List<AllBoardData> allBoardData10 = projectInfoMapper.getJSK();
//        得到单位的应收账款--进度款
        List<AllBoardData> allBoardData11 = projectInfoMapper.getJDK();

//        封装数据
        for (AllBoardData allBoardDatum : allBoardData) {
//            封装投标数量
            for (AllBoardData boardData : allBoardData1) {
                if (boardData.getDeptName().equals(allBoardDatum.getDeptName())) {
                    allBoardDatum.setBidNumber(boardData.getBidNumber());
                }
            }
//            封装中标数量
            for (AllBoardData boardData : allBoardData2) {
                if (boardData.getDeptName().equals(allBoardDatum.getDeptName())) {
                    allBoardDatum.setBidBackNumber(boardData.getBidBackNumber());
                }
            }
//             封装收入确认
            for (AllBoardData boardData : allBoardData6) {
                if (allBoardDatum.getDeptName().equals(boardData.getDeptName())) {
                    allBoardDatum.setSRQRByYear(boardData.getSRQRByYear());
                }
            }
//            封装开票金额
            for (AllBoardData boardData : allBoardData7) {
                if (boardData.getDeptName().equals(allBoardDatum.getDeptName())) {
                    allBoardDatum.setKPMoneyByYear(boardData.getKPMoneyByYear());
                }
            }
//            封装立项数量
            for (AllBoardData boardData : allBoardData8) {
                if (boardData.getDeptName().equals(allBoardDatum.getDeptName())) {
                    allBoardDatum.setLXProject(boardData.getLXProject());
                }
            }
//            封装关闭数量
            for (AllBoardData boardData : allBoardData9) {
                if (boardData.getDeptName().equals(allBoardDatum.getDeptName())) {
                    allBoardDatum.setNumberProjectFinish(boardData.getNumberProjectFinish());
                }
            }
//            封装应收账款结算款
            for (AllBoardData boardData : allBoardData10) {
                if (boardData.getDeptName().equals(allBoardDatum.getDeptName())) {
                    allBoardDatum.setYSZKJSK(boardData.getYSZKJSK());
                }
            }
//            封装应收账款进度款
            for (AllBoardData boardData : allBoardData11) {
                if (boardData.getDeptName().equals(allBoardDatum.getDeptName())) {
                    allBoardDatum.setYSZKJDK(boardData.getYSZKJDK());
                }
            }
//            封装流入金额
            for (AllBoardData boardData : allBoardData3) {
                if (boardData.getDeptName().equals(allBoardDatum.getDeptName())) {
                    allBoardDatum.setXJLRYear(boardData.getXJLRYear());
                }
            }
//            封装流出金额
            for (AllBoardData boardData : allBoardData4) {
                if (boardData.getDeptName().equals(allBoardDatum.getDeptName())) {
                    allBoardDatum.setXJLCYear(boardData.getXJLCYear());
                }
            }
//            封装合同签订金额
            for (AllBoardData boardData : allBoardData5) {
                if (boardData.getDeptName().equals(allBoardDatum.getDeptName())) {
                    allBoardDatum.setContractFee(boardData.getContractFee());
                }
            }
//            对字段进行统一处理
            if (allBoardDatum.getBidNumber() == null) {
                allBoardDatum.setBidNumber(0);
            }
            if (allBoardDatum.getBidBackNumber() == null) {
                allBoardDatum.setBidBackNumber(0);
            }
            if (allBoardDatum.getLXProject() == null) {
                allBoardDatum.setLXProject(0);
            }
            if (allBoardDatum.getContractFee() == null) {
                allBoardDatum.setContractFee(0L);
            }
            if (allBoardDatum.getXJLRYear() == null) {
                allBoardDatum.setXJLRYear(0L);
            }
            if (allBoardDatum.getXJLCYear() == null) {
                allBoardDatum.setXJLCYear(0L);
            }
            if (allBoardDatum.getContractFee() == null) {
                allBoardDatum.setContractFee(0L);
            }
            if (allBoardDatum.getSRQRByYear() == null) {
                allBoardDatum.setSRQRByYear(0L);
            }
            if (allBoardDatum.getKPMoneyByYear() == null) {
                allBoardDatum.setKPMoneyByYear(0L);
            }
            if (allBoardDatum.getNumberProjectFinish() == null) {
                allBoardDatum.setNumberProjectFinish(0);
            }
            if (allBoardDatum.getYSZKJDK() == null) {
                allBoardDatum.setYSZKJDK(0L);
            }
            if (allBoardDatum.getYSZKJSK() == null) {
                allBoardDatum.setYSZKJSK(0L);
            }
        }
        return allBoardData;
    }


    /**
     * 获取首页数据--本年
     */
    @Override
    public List<SYData> getSYData() {
//        得到所有单位名称
        List<SYData> list = projectInfoMapper.getDept();
//        得到单位的投标数,投标金额
        List<SYData> list1 = projectInfoMapper.getBidInfo();
//        得到单位的中标数，中标金额
        List<SYData> list2 = projectInfoMapper.getBidBackInfo();
//        得到单位的合同签订数量，金额
        List<SYData> list3 = projectInfoMapper.getContractInfo();//1
//        得到流入金额
        List<SYData> list4 = projectInfoMapper.getLRMoney();//1
//        得到流出金额
        List<SYData> list5 = projectInfoMapper.getLCMoney();//1
//        得到单位的应收账款--应收账款结算款
        List<SYData> list6 = projectInfoMapper.getJSMoney();
//        得到单位的应收账款--应收账款进度款
        List<SYData> list7 = projectInfoMapper.getJDMoney();
//        得到单位的收入确认金额
        List<SYData> list8 = projectInfoMapper.getSRQRMoney();
//        得到单位的开票金额
        List<SYData> list9 = projectInfoMapper.getKPJEMoney();
//        得到单位的收票金额
        List<SYData> list10 = projectInfoMapper.getSPJEMoney();
//        得到单位的项目情况--立项项目数量，金额
        List<SYData> list11 = projectInfoMapper.getLX();
//        得到单位的项目情况--关闭项目数量，金额
        List<SYData> list12 = projectInfoMapper.getGB();
//        得到单位的项目情况--在建项目数量，金额
        List<SYData> list13 = projectInfoMapper.getZJ();
//        开始封装数据
        if (list != null) {
            for (SYData syData : list) {
//                封装投标数量金额
                if (list1 != null) {
                    for (SYData data : list1) {
                        if (data.getDeptName().equals(syData.getDeptName())) {
                            syData.setBidNumber(data.getBidNumber());
                            syData.setBidMoney(data.getBidMoney());
                        }
                    }
                }
//                封装中标数量金额
                if (list2 != null) {
                    for (SYData data : list2) {
                        if (data.getDeptName().equals(syData.getDeptName())) {
                            syData.setBidBackNumber(data.getBidBackNumber());
                            syData.setBidBackMoney(data.getBidBackMoney());
                        }
                    }
                }
//                封装合同签订数量，金额
                if (list3 != null) {
                    for (SYData data : list3) {
                        if (data.getDeptName().equals(syData.getDeptName())) {
                            syData.setContractNumber(data.getContractNumber());
                            syData.setContractMoney(data.getContractMoney());
                        }
                    }
                }
//                封装流入金额
                if (list4 != null) {
                    for (SYData data : list4) {
                        if (data.getDeptName().equals(syData.getDeptName())) {
                            syData.setXjlr(data.getXjlr());
                        }
                    }
                }
//                封装流出金额
                if (list5 != null) {
                    for (SYData data : list5) {
                        if (data.getDeptName().equals(syData.getDeptName())) {
                            syData.setXjlc(data.getXjlc());
                        }
                    }
                }
//                封装应收账款结算款
                if (list6 != null) {
                    for (SYData data : list6) {
                        if (data.getDeptName().equals(syData.getDeptName())) {
                            syData.setYszkjsk(data.getYszkjsk());
                        }
                    }
                }
//                封装应收账款进度款
                if (list7 != null) {
                    for (SYData data : list7) {
                        if (data.getDeptName().equals(syData.getDeptName())) {
                            syData.setYszkjdk(data.getYszkjdk());
                        }
                    }
                }
//                封装收入确认金额
                if (list8 != null) {
                    for (SYData data : list8) {
                        if (data.getDeptName().equals(syData.getDeptName())) {
                            syData.setSrqrMoney(data.getSrqrMoney());
                        }
                    }
                }
//                封装开票金额
                if (list9 != null) {
                    for (SYData data : list9) {
                        if (data.getDeptName().equals(syData.getDeptName())) {
                            syData.setKpjeMoney(data.getKpjeMoney());
                        }
                    }
                }
//                封装收票金额
                if (list10 != null) {
                    for (SYData data : list10) {
                        if (data.getDeptName().equals(syData.getDeptName())) {
                            syData.setSpjeMoney(data.getSpjeMoney());
                        }
                    }
                }
//                封装立项数量，金额
                if (list11 != null) {
                    for (SYData data : list11) {
                        if (data.getDeptName().equals(syData.getDeptName())) {
                            syData.setLxNumber(data.getLxNumber());
                            syData.setLxMoney(data.getLxMoney());
                        }
                    }
                }
//                封装关闭数量，金额
                if (list12 != null) {
                    for (SYData data : list12) {
                        if (data.getDeptName().equals(syData.getDeptName())) {
                            syData.setGbNumber(data.getGbNumber());
                            syData.setGbMoney(data.getGbMoney());
                        }
                    }
                }
//                封装在建项目数量，金额
                if (list13 != null) {
                    for (SYData data : list13) {
                        if (data.getDeptName().equals(syData.getDeptName())) {
                            syData.setZjNumber(data.getZjNumber());
                            syData.setZjMoney(data.getZjMoney());
                        }
                    }
                }
//                对实体类进行判空处理
                if (syData.getBidNumber() == null) {
                    syData.setBidNumber(0);
                }
                if (syData.getBidMoney() == null) {
                    syData.setBidMoney(0L);
                }
                if (syData.getBidBackNumber() == null) {
                    syData.setBidBackNumber(0);
                }
                if (syData.getBidBackMoney() == null) {
                    syData.setBidBackMoney(0L);
                }
                if (syData.getContractNumber() == null) {
                    syData.setContractNumber(0);
                }
                if (syData.getContractMoney() == null) {
                    syData.setContractMoney(0L);
                }
                if (syData.getXjlr() == null) {
                    syData.setXjlr(0L);
                }
                if (syData.getXjlc() == null) {
                    syData.setXjlc(0L);
                }
                if (syData.getYszkjsk() == null) {
                    syData.setYszkjsk(0L);
                }
                if (syData.getYszkjdk() == null) {
                    syData.setYszkjdk(0L);
                }
                if (syData.getSrqrMoney() == null) {
                    syData.setSrqrMoney(0L);
                }
                if (syData.getKpjeMoney() == null) {
                    syData.setKpjeMoney(0L);
                }
                if (syData.getSpjeMoney() == null) {
                    syData.setSpjeMoney(0L);
                }
                if (syData.getLxNumber() == null) {
                    syData.setLxNumber(0);
                }
                if (syData.getLxMoney() == null) {
                    syData.setLxMoney(0L);
                }
                if (syData.getGbNumber() == null) {
                    syData.setGbNumber(0);
                }
                if (syData.getGbMoney() == null) {
                    syData.setGbMoney(0L);
                }
                if (syData.getZjNumber() == null) {
                    syData.setZjNumber(0);
                }
                if (syData.getZjMoney() == null) {
                    syData.setZjMoney(0L);
                }
            }
        }
        return list;
    }


    /**
     * 获取首页数据--本月
     */
    @Override
    public List<SYData> getSYDataByMonth() {
        //        得到所有单位名称
        List<SYData> list = projectInfoMapper.getDept();
//        得到单位的投标数,投标金额
        List<SYData> list1 = projectInfoMapper.getBidInfoByMonth();
//        得到单位的中标数，中标金额
        List<SYData> list2 = projectInfoMapper.getBidBackInfoByMonth();
//        得到单位的合同签订数量，金额
        List<SYData> list3 = projectInfoMapper.getContractInfoByMonth();//1
//        得到流入金额
        List<SYData> list4 = projectInfoMapper.getLRMoneyByMonth();//1
//        得到流出金额
        List<SYData> list5 = projectInfoMapper.getLCMoneyByMonth();//1
//        得到单位的应收账款--应收账款结算款
        List<SYData> list6 = projectInfoMapper.getJSMoneyByMonth();
//        得到单位的应收账款--应收账款进度款
        List<SYData> list7 = projectInfoMapper.getJDMoneyByMonth();
//        得到单位的收入确认金额
        List<SYData> list8 = projectInfoMapper.getSRQRMoneyByMonth();
//        得到单位的开票金额
        List<SYData> list9 = projectInfoMapper.getKPJEMoneyByMonth();
//        得到单位的收票金额
        List<SYData> list10 = projectInfoMapper.getSPJEMoneyByMonth();
//        得到单位的项目情况--立项项目数量，金额
        List<SYData> list11 = projectInfoMapper.getLXByMonth();
//        得到单位的项目情况--关闭项目数量，金额
        List<SYData> list12 = projectInfoMapper.getGBByMonth();
//        得到单位的项目情况--在建项目数量，金额
        List<SYData> list13 = projectInfoMapper.getZJByMonth();
//        开始封装数据
        if (list != null) {
            for (SYData syData : list) {
//                封装投标数量金额
                if (list1 != null) {
                    for (SYData data : list1) {
                        if (data.getDeptName().equals(syData.getDeptName())) {
                            syData.setBidNumber(data.getBidNumber());
                            syData.setBidMoney(data.getBidMoney());
                        }
                    }
                }
//                封装中标数量金额
                if (list2 != null) {
                    for (SYData data : list2) {
                        if (data.getDeptName().equals(syData.getDeptName())) {
                            syData.setBidBackNumber(data.getBidBackNumber());
                            syData.setBidBackMoney(data.getBidBackMoney());
                        }
                    }
                }
//                封装合同签订数量，金额
                if (list3 != null) {
                    for (SYData data : list3) {
                        if (data.getDeptName().equals(syData.getDeptName())) {
                            syData.setContractNumber(data.getContractNumber());
                            syData.setContractMoney(data.getContractMoney());
                        }
                    }
                }
//                封装流入金额
                if (list4 != null) {
                    for (SYData data : list4) {
                        if (data.getDeptName().equals(syData.getDeptName())) {
                            syData.setXjlr(data.getXjlr());
                        }
                    }
                }
//                封装流出金额
                if (list5 != null) {
                    for (SYData data : list5) {
                        if (data.getDeptName().equals(syData.getDeptName())) {
                            syData.setXjlc(data.getXjlc());
                        }
                    }
                }
//                封装应收账款结算款
                if (list6 != null) {
                    for (SYData data : list6) {
                        if (data.getDeptName().equals(syData.getDeptName())) {
                            syData.setYszkjsk(data.getYszkjsk());
                        }
                    }
                }
//                封装应收账款进度款
                if (list7 != null) {
                    for (SYData data : list7) {
                        if (data.getDeptName().equals(syData.getDeptName())) {
                            syData.setYszkjdk(data.getYszkjdk());
                        }
                    }
                }
//                封装收入确认金额
                if (list8 != null) {
                    for (SYData data : list8) {
                        if (data.getDeptName().equals(syData.getDeptName())) {
                            syData.setSrqrMoney(data.getSrqrMoney());
                        }
                    }
                }
//                封装开票金额
                if (list9 != null) {
                    for (SYData data : list9) {
                        if (data.getDeptName().equals(syData.getDeptName())) {
                            syData.setKpjeMoney(data.getKpjeMoney());
                        }
                    }
                }
//                封装收票金额
                if (list10 != null) {
                    for (SYData data : list10) {
                        if (data.getDeptName().equals(syData.getDeptName())) {
                            syData.setSpjeMoney(data.getSpjeMoney());
                        }
                    }
                }
//                封装立项数量，金额
                if (list11 != null) {
                    for (SYData data : list11) {
                        if (data.getDeptName().equals(syData.getDeptName())) {
                            syData.setLxNumber(data.getLxNumber());
                            syData.setLxMoney(data.getLxMoney());
                        }
                    }
                }
//                封装关闭数量，金额
                if (list12 != null) {
                    for (SYData data : list12) {
                        if (data.getDeptName().equals(syData.getDeptName())) {
                            syData.setGbNumber(data.getGbNumber());
                            syData.setGbMoney(data.getGbMoney());
                        }
                    }
                }
//                封装在建项目数量，金额
                if (list13 != null) {
                    for (SYData data : list13) {
                        if (data.getDeptName().equals(syData.getDeptName())) {
                            syData.setZjNumber(data.getZjNumber());
                            syData.setZjMoney(data.getZjMoney());
                        }
                    }
                }
//                对实体类进行判空处理
                if (syData.getBidNumber() == null) {
                    syData.setBidNumber(0);
                }
                if (syData.getBidMoney() == null) {
                    syData.setBidMoney(0L);
                }
                if (syData.getBidBackNumber() == null) {
                    syData.setBidBackNumber(0);
                }
                if (syData.getBidBackMoney() == null) {
                    syData.setBidBackMoney(0L);
                }
                if (syData.getContractNumber() == null) {
                    syData.setContractNumber(0);
                }
                if (syData.getContractMoney() == null) {
                    syData.setContractMoney(0L);
                }
                if (syData.getXjlr() == null) {
                    syData.setXjlr(0L);
                }
                if (syData.getXjlc() == null) {
                    syData.setXjlc(0L);
                }
                if (syData.getYszkjsk() == null) {
                    syData.setYszkjsk(0L);
                }
                if (syData.getYszkjdk() == null) {
                    syData.setYszkjdk(0L);
                }
                if (syData.getSrqrMoney() == null) {
                    syData.setSrqrMoney(0L);
                }
                if (syData.getKpjeMoney() == null) {
                    syData.setKpjeMoney(0L);
                }
                if (syData.getSpjeMoney() == null) {
                    syData.setSpjeMoney(0L);
                }
                if (syData.getLxNumber() == null) {
                    syData.setLxNumber(0);
                }
                if (syData.getLxMoney() == null) {
                    syData.setLxMoney(0L);
                }
                if (syData.getGbNumber() == null) {
                    syData.setGbNumber(0);
                }
                if (syData.getGbMoney() == null) {
                    syData.setGbMoney(0L);
                }
                if (syData.getZjNumber() == null) {
                    syData.setZjNumber(0);
                }
                if (syData.getZjMoney() == null) {
                    syData.setZjMoney(0L);
                }
            }
        }
        return list;
    }

    /**
     * 获取项目金额
     */
    @Override
    public List<ProjectInfo> getProjectAmount() {
        List<ProjectInfo> list = projectInfoMapper.getProjectAmount();
        return list;
    }

    /**
     * 获取单位名称
     */
    @Override
    public List<ProjectInfo> getdept() {
        List<ProjectInfo> list = projectInfoMapper.getdept();
        return list;
    }


    /**
     * 在建大项目排行--带时间
     */
    @Override
    public List<ProjectInfo> zjprojectorder(PageVo page, SearchVo searchVo) {
        int pageSize = page.getPageSize();
        int pageNumber = (page.getPageNumber() - 1) * pageSize;
        String startDate = searchVo.getStartDate();
        String endDate = searchVo.getEndDate();
        List<ProjectInfo> list = projectInfoMapper.zjprojectorder1(startDate, endDate);
        List<ProjectInfo> list1 = projectInfoMapper.zjprojectorder(pageSize, pageNumber, startDate, endDate);
        if (list != null) {
            for (ProjectInfo projectInfo : list1) {
                projectInfo.setTotal(list.size());
            }
        }
        return list1;
    }

    /**
     * 在建大项目排行--不带时间
     */
    @Override
    public List<ProjectInfo> zjprojectordernull(PageVo page) {
        int pageSize = page.getPageSize();
        int pageNumber = (page.getPageNumber() - 1) * pageSize;
        List<ProjectInfo> list = projectInfoMapper.zjprojectordernull1();
        List<ProjectInfo> list1 = projectInfoMapper.zjprojectordernull(pageSize, pageNumber);
        if (list != null) {
            for (ProjectInfo projectInfo : list1) {
                projectInfo.setTotal(list.size());
            }
        }
        return list1;
    }

    /**
     * 立项大项目排行--带时间
     */
    @Override
    public List<ProjectInfo> lxprojectorder(PageVo page, SearchVo searchVo) {
        int pageSize = page.getPageSize();
        int pageNumber = (page.getPageNumber() - 1) * pageSize;
        String startDate = searchVo.getStartDate();
        String endDate = searchVo.getEndDate();
        List<ProjectInfo> list = projectInfoMapper.lxprojectorder1(startDate, endDate);
        List<ProjectInfo> list1 = projectInfoMapper.lxprojectorder(pageSize, pageNumber, startDate, endDate);
        if (list != null) {
            for (ProjectInfo projectInfo : list1) {
                projectInfo.setTotal(list.size());
            }
        }
        return list1;
    }

    /**
     * 立项大项目排行--不带时间
     */
    @Override
    public List<ProjectInfo> lxprojectordernull(PageVo page) {
        int pageSize = page.getPageSize();
        int pageNumber = (page.getPageNumber() - 1) * pageSize;
        List<ProjectInfo> list = projectInfoMapper.lxprojectordernull1();
        List<ProjectInfo> list1 = projectInfoMapper.lxprojectordernull(pageSize, pageNumber);
        if (list != null) {
            for (ProjectInfo projectInfo : list1) {
                projectInfo.setTotal(list.size());
            }
        }
        return list1;
    }

    /**
     * 关闭大项目排行--带时间
     */
    @Override
    public List<ProjectInfo> gbprojectorder(PageVo page, SearchVo searchVo) {
        int pageSize = page.getPageSize();
        int pageNumber = (page.getPageNumber() - 1) * pageSize;
        String startDate = searchVo.getStartDate();
        String endDate = searchVo.getEndDate();
        List<ProjectInfo> list = projectInfoMapper.gbprojectorder1(startDate, endDate);
        List<ProjectInfo> list1 = projectInfoMapper.gbprojectorder(pageSize, pageNumber, startDate, endDate);
        if (list != null) {
            for (ProjectInfo projectInfo : list1) {
                projectInfo.setTotal(list.size());
            }
        }
        return list1;
    }

    /**
     * 关闭大项目排行--不带时间
     */
    @Override
    public List<ProjectInfo> gbprojectordernull(PageVo page) {
        int pageSize = page.getPageSize();
        int pageNumber = (page.getPageNumber() - 1) * pageSize;
        List<ProjectInfo> list = projectInfoMapper.gbprojectordernull1();
        List<ProjectInfo> list1 = projectInfoMapper.gbprojectordernull(pageSize, pageNumber);
        if (list != null) {
            for (ProjectInfo projectInfo : list1) {
                projectInfo.setTotal(list.size());
            }
        }
        return list1;
    }


    /**
     * 公司不同状态下的数量和金额总数
     */
    @Override
    public List<CompanyNumberAmount> getCompanyNumberAmount(String str) {

        List<CompanyNumberAmount> list = projectInfoMapper.getCompanyNumberAmount();

        //本月业务关闭
        List<CompanyNumberAmount> mlist = projectInfoMapper.getCompanyNumberAmountMonth();

        //本年业务关闭
        List<CompanyNumberAmount> ylist = projectInfoMapper.getCompanyNumberAmountYear();

        Map<String, List<CompanyNumberAmount>> groupedObjects = new HashMap<>();

        Map<String, List<CompanyNumberAmount>> groupedObjectsMonth = new HashMap<>();

        Map<String, List<CompanyNumberAmount>> groupedObjectsYear = new HashMap<>();

        // 将对象按照属性orgName的值进行分组
        for (CompanyNumberAmount object : list) {
            String key = object.getOrgName();
            List<CompanyNumberAmount> group = groupedObjects.getOrDefault(key, new ArrayList<>());
            group.add(object);
            groupedObjects.put(key, group);
        }

        for (CompanyNumberAmount object : mlist) {
            String key = object.getOrgName();
            List<CompanyNumberAmount> groupMonth = groupedObjectsMonth.getOrDefault(key, new ArrayList<>());
            groupMonth.add(object);
            groupedObjectsMonth.put(key, groupMonth);
        }

        for (CompanyNumberAmount object : ylist) {
            String key = object.getOrgName();
            List<CompanyNumberAmount> groupYear = groupedObjectsYear.getOrDefault(key, new ArrayList<>());
            groupYear.add(object);
            groupedObjectsYear.put(key, groupYear);
        }

        List<CompanyNumberAmount> cList = new ArrayList<>();

        for (Map.Entry<String, List<CompanyNumberAmount>> entry : groupedObjects.entrySet()) {
            String key = entry.getKey();
            List<CompanyNumberAmount> group = entry.getValue();

            CompanyNumberAmount companyNumberAmount = new CompanyNumberAmount();

            companyNumberAmount.setCompanyName(key);

            for(CompanyNumberAmount c : group){
                if(c.getState().equals("验收") ){
                    companyNumberAmount.setGcacceptNum(c.getNum());
                    companyNumberAmount.setGcacceptAmount(c.getSum());
                }
                if(c.getState().equals("审计") ){
                    companyNumberAmount.setGcauditNum(c.getNum());
                    companyNumberAmount.setGcauditAmount(c.getSum());
                }
                if(c.getState().equals("未开工") ){
                    companyNumberAmount.setGcbfstartNum(c.getNum());
                    companyNumberAmount.setGcbfstartAmount(c.getSum());
                }
                if(c.getState().equals("在建") ){
                    companyNumberAmount.setGcbuildNum(c.getNum());
                    companyNumberAmount.setGcbuildAmount(c.getSum());
                }
                if(c.getState().equals("业务关闭") ){
                    if(str != null){
                        if(str.equals("month")){
                            for (Map.Entry<String, List<CompanyNumberAmount>> entry1 : groupedObjectsMonth.entrySet()) {
                                String key1 = entry1.getKey();
                                List<CompanyNumberAmount> group1 = entry1.getValue();
                                if(key1.equals(key)){
                                    for(CompanyNumberAmount c1 : group1){
                                        companyNumberAmount.setGcbusinessNum(c1.getNum());
                                        companyNumberAmount.setGcbusinessAmount(c1.getSum());
                                    }
                                }
                            }
                        }
                        if(str.equals("year")){
                            for (Map.Entry<String, List<CompanyNumberAmount>> entry2 : groupedObjectsYear.entrySet()) {
                                String key2 = entry2.getKey();
                                List<CompanyNumberAmount> group2 = entry2.getValue();
                                if(key2.equals(key)){
                                    for(CompanyNumberAmount c2 : group2){
                                        companyNumberAmount.setGcbusinessNum(c2.getNum());
                                        companyNumberAmount.setGcbusinessAmount(c2.getSum());
                                    }
                                }
                            }
                        }
                    }else {
                        companyNumberAmount.setGcbusinessNum(c.getNum());
                        companyNumberAmount.setGcbusinessAmount(c.getSum());
                    }

                }
                if(c.getState().equals("财务关闭") ){
                    companyNumberAmount.setGcfinancialNum(c.getNum());
                    companyNumberAmount.setGcfinancialAmount(c.getSum());
                }
                if(c.getState().equals("完工")){
                    companyNumberAmount.setGcfinishNum(c.getNum());
                    companyNumberAmount.setGcfinishAmount(c.getSum());
                }
                if(c.getState().equals("监理工作审计") ){
                    companyNumberAmount.setJlprojauditNum(c.getNum());
                    companyNumberAmount.setJlprojauditAmount(c.getSum());
                }
                if(c.getState().equals("监理工作实施") ){
                    companyNumberAmount.setJlworkimplementNum(c.getNum());
                    companyNumberAmount.setJlworkimplementAmount(c.getSum());
                }
                if(c.getState().equals("监理工作准备") ){
                    companyNumberAmount.setJlworkreadinessNum(c.getNum());
                    companyNumberAmount.setJlworkreadinessAmount(c.getSum());
                }
                if(c.getState().equals("监理工作总结") ){
                    companyNumberAmount.setJlworksummaryNum(c.getNum());
                    companyNumberAmount.setJlworksummaryAmount(c.getSum());
                }
                if(c.getState().equals("资料收集") ){
                    companyNumberAmount.setSjdatacollectionNum(c.getNum());
                    companyNumberAmount.setSjdatacollectionAmount(c.getSum());
                }
                if(c.getState().equals("文件编制") ){
                    companyNumberAmount.setSjdocumentationNum(c.getNum());
                    companyNumberAmount.setSjdocumentationAmount(c.getSum());
                }
                if(c.getState().equals("外部评审") ){
                    companyNumberAmount.setSjexternalreviewNum(c.getNum());
                    companyNumberAmount.setSjexternalreviewAmount(c.getSum());
                }
                if(c.getState().equals("内部评审") ){
                    companyNumberAmount.setSjinternalreviewNum(c.getNum());
                    companyNumberAmount.setSjinternalreviewAmount(c.getSum());
                }
                if(c.getState().equals("出版交付") ){
                    companyNumberAmount.setSjpublishdeliveryNum(c.getNum());
                    companyNumberAmount.setSjpublishdeliveryAmount(c.getSum());
                }
                if(c.getState().equals("研发在建") ){
                    companyNumberAmount.setYfbuildNum(c.getNum());
                    companyNumberAmount.setYfbuildAmount(c.getSum());
                }

            }


            Field[] fields = companyNumberAmount.getClass().getDeclaredFields();
            for (Field field : fields) {
                field.setAccessible(true);
                try {
                    // 判断属性值是否为null
                    if (field.get(companyNumberAmount) == null) {
                        // 设置默认值
                        if (field.getType() == Integer.class) {
                            field.set(companyNumberAmount, 0);
                        }
                        if (field.getType() == Long.class) {
                            field.set(companyNumberAmount, 0L);
                        }
                    }
                } catch (IllegalAccessException e) {
                    e.printStackTrace();
                }
            }

            cList.add(companyNumberAmount);
        }

        return cList;
    }

    @Override
    public List<ProjectTypeAnalysis> getProjectTypeAnalysis(String str) {

        List<ProjectTypeAnalysis> pList = new ArrayList<>();

        List<ProjectTypeAnalysis> list =  projectInfoMapper.getProjectTypeAnalysis();

        List<ProjectTypeAnalysis> list1 =  projectInfoMapper.getOverallProjectTypeAnalysis();

        Map<String, List<ProjectTypeAnalysis>> map = new HashMap<>();

        for (ProjectTypeAnalysis object : list) {
            String key = object.getOrgName();
            List<ProjectTypeAnalysis> projectTypeAnalysisList = map.getOrDefault(key, new ArrayList<>());
            projectTypeAnalysisList.add(object);
            map.put(key, projectTypeAnalysisList);
        }

        for (Map.Entry<String, List<ProjectTypeAnalysis>> entry : map.entrySet()) {
            String key = entry.getKey();
            List<ProjectTypeAnalysis> group = entry.getValue();

            ProjectTypeAnalysis projectTypeAnalysis = new ProjectTypeAnalysis();

            projectTypeAnalysis.setOrgName(key);

            for(ProjectTypeAnalysis p : group){
                if(p.getType().equals("工程项目")){
                    projectTypeAnalysis.setGcNum(p.getNum());
                    projectTypeAnalysis.setGcAmount(p.getSum());
                }
                if(p.getType().equals("监理项目")){
                    projectTypeAnalysis.setJlNum(p.getNum());
                    projectTypeAnalysis.setJlAmount(p.getSum());
                }
                if(p.getType().equals("其它项目")){
                    projectTypeAnalysis.setQtNum(p.getNum());
                    projectTypeAnalysis.setQtAmount(p.getSum());
                }
                if(p.getType().equals("设计项目")){
                    projectTypeAnalysis.setSjNum(p.getNum());
                    projectTypeAnalysis.setSjAmount(p.getSum());
                }
                if(p.getType().equals("维护项目")){
                    projectTypeAnalysis.setWhNum(p.getNum());
                    projectTypeAnalysis.setWhAmount(p.getSum());
                }
                if(p.getType().equals("研发项目")){
                    projectTypeAnalysis.setYfNum(p.getNum());
                    projectTypeAnalysis.setYfAmount(p.getSum());
                }
            }

            Field[] fields = projectTypeAnalysis.getClass().getDeclaredFields();
            for (Field field : fields) {
                field.setAccessible(true);
                try {
                    // 判断属性值是否为null
                    if (field.get(projectTypeAnalysis) == null) {
                        // 设置默认值
                        if (field.getType() == Integer.class) {
                            field.set(projectTypeAnalysis, 0);
                        }
                        if (field.getType() == Long.class) {
                            field.set(projectTypeAnalysis, 0L);
                        }
                    }
                } catch (IllegalAccessException e) {
                    e.printStackTrace();
                }
            }

            pList.add(projectTypeAnalysis);

        }

        for(ProjectTypeAnalysis p : pList){
            for(ProjectTypeAnalysis p1 : list1){
                if(p.getOrgName().equals(p1.getOrgName())){
                    p.setOverallNum(p1.getNum());
                    p.setOverallAmount(p1.getSum());
                }
            }
        }



        return pList;
    }
}
